package cn.wolfcode.domain;

import cn.wolfcode.myenum.NoticeEnum;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class Notice {
    /**
     *
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    /**
     * 标题名
     */
    private String title;

    /**
     * 创建人
     */
    private Long creationId;
    @TableField(exist = false)
    private Employee creation;

    /**
     * 创建时间
     */
    private Date creationTime;

    /**
     * 公告等级
     */
    private Integer level;

    /**
     * 发布状态
     */
    private boolean status;

    /**
     * 文本内容
     */
    private String text;

    /**
     * 多久没看公告了
     */
    @TableField(exist = false)
    private String intervalTime;

    public String getLevelName() {
        return NoticeEnum.findName(level);
    }

    public String toJson() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("textValue", text);
        map.put("level", level);
        return JSON.toJSONString(map);
    }
}